package com.vcit.clazzGroup.creoller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.vcit.system.service.clazzGroup.ITClazzGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vcit.common.annotation.Log;
import com.vcit.common.core.controller.BaseController;
import com.vcit.common.core.domain.AjaxResult;
import com.vcit.common.enums.BusinessType;
import com.vcit.system.domain.clazzGroup.TClazzGroup;

import com.vcit.common.utils.poi.ExcelUtil;
import com.vcit.common.core.page.TableDataInfo;

/**
 * 班级群Controller
 * 
 * @author dff
 * @date 2025-01-09
 */
@RestController
@RequestMapping("/system/group")
@Api("班级群组信息管理")
public class TClazzGroupController extends BaseController
{
    @Autowired
    private ITClazzGroupService tClazzGroupService;

    /**
     * 查询班级群列表
     */
    @ApiOperation("获取班级群信息列表")
   // @PreAuthorize("@ss.hasPermi('system:group:list')")
    @GetMapping("/list")
    public TableDataInfo list(TClazzGroup tClazzGroup)
    {
        startPage();
        List<TClazzGroup> list = tClazzGroupService.selectTClazzGroupList(tClazzGroup);
        return getDataTable(list);
    }

    /**
     * 导出班级群列表
     */
    @ApiOperation("导出班级群信息列表")
    @PreAuthorize("@ss.hasPermi('system:group:export')")
    @Log(title = "班级群", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TClazzGroup tClazzGroup)
    {
        List<TClazzGroup> list = tClazzGroupService.selectTClazzGroupList(tClazzGroup);
        ExcelUtil<TClazzGroup> util = new ExcelUtil<TClazzGroup>(TClazzGroup.class);
        util.exportExcel(response, list, "班级群数据");
    }

    /**
     * 获取班级群详细信息
     */
    @ApiOperation("获取班级群详细信息")
    @PreAuthorize("@ss.hasPermi('system:group:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tClazzGroupService.selectTClazzGroupById(id));
    }

    /**
     * 新增班级群
     */
    @ApiOperation("新增班级群信息")
    @PreAuthorize("@ss.hasPermi('system:group:add')")
    @Log(title = "班级群", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TClazzGroup tClazzGroup)
    {
        return toAjax(tClazzGroupService.insertTClazzGroup(tClazzGroup));
    }

    /**
     * 修改班级群
     */
    @ApiOperation("修改班级群信息")
    @PreAuthorize("@ss.hasPermi('system:group:edit')")
    @Log(title = "班级群", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TClazzGroup tClazzGroup)
    {
        return toAjax(tClazzGroupService.updateTClazzGroup(tClazzGroup));
    }

    /**
     * 删除班级群
     */
    @ApiOperation("删除班级群信息")
    @PreAuthorize("@ss.hasPermi('system:group:remove')")
    @Log(title = "班级群", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tClazzGroupService.deleteTClazzGroupByIds(ids));
    }
}
